#pragma once

#include <utility>
#include <vector>

namespace jianzhi_030
{

class MinStack {
public:
    void push(int x)
    {
        m_stack.push_back(x);
        if (m_min_stack.empty())
            m_min_stack.push_back(x);
        else
            m_min_stack.push_back(std::min(m_min_stack.back(), x));
    }

    void pop()
    {
        m_stack.pop_back();
        m_min_stack.pop_back();
    }

    int top()
    {
        return m_stack.back();
    }

    int min()
    {
        return m_min_stack.back();
    }

private:
    std::vector<int> m_stack;
    std::vector<int> m_min_stack;
};

}  /* namespace jianzhi_030 */
